<template>
  <div>
    <el-form :model="dataForm" label-position="left" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
    <el-form-item label="检测结果" prop="status" >
      <el-tag type="warning">开始认证</el-tag>
      <!-- <el-tag type="success" v-if="dataForm.status == 1">完成认证</el-tag> -->
    </el-form-item>
    <el-form-item label="权限等级" prop="level" >
      <el-tag v-if="dataForm.level == 1">免费使用</el-tag>
      <el-tag v-if="dataForm.level == 2">按量付费</el-tag>
      <el-tag v-if="dataForm.level == 3">按月付费</el-tag>
    </el-form-item>
    <el-form-item label="用户名" prop="username">
      <el-input v-model="dataForm.username" placeholder="用户名" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="设备数" prop="count">
      <el-input-number v-model="dataForm.count" :min="1" :disabled="true" :max="1000" label="发放设备token的数量"></el-input-number>
      <!-- <el-input v-model="dataForm.count" placeholder="发放设备token的数量"></el-input> -->
    </el-form-item>
    <el-form-item label="电话" prop="phone">
      <el-input v-model="dataForm.phone" placeholder="电话" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="密钥" prop="key" >
      <el-input v-model="dataForm.key" placeholder="密钥(默认可以不填)" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="邮箱" prop="email">
      <el-input v-model="dataForm.email" placeholder="邮箱" :disabled="true"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="dataFormSubmit()">发送验证码</el-button>
    </span>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        vcode:"",//验证码
        levelText:"",
        statusText:"",
        readSwitch: true,
        // dataForm: this.dataFormParent,
      }
    },
    props:['dataForm'],
    methods: {
    //   init (id) {
    //     this.$http({
    //       url: this.$http.adornUrl(`/product/consumer/reg/check/${id}`),
    //       method: 'get',
    //     }).then(({data}) => {
    //       if (data && data.code === 0) {
    //         this.dataForm.username = data.data.username
    //         this.dataForm.email = data.data.email
    //         this.dataForm.phone = data.data.phone
    //         this.dataForm.count = data.data.count
    //         this.dataForm.level = data.data.level
    //         if( data.data.status == 0){
    //             this.dataForm.status = "warning"
    //             this.statusText = "等待认证"
    //         }
    //         if( data.data.status == 1){
    //             this.dataForm.status = "success"
    //             this.statusText = "完成认证"
    //         }
    //         if (this.dataForm.level == 1){
    //             this.levelText = "免费使用"
    //         }else if(this.dataForm.level == 2){
    //              this.levelText = "按量付费"
    //         }else{
    //             this.levelText = "按月付费"
    //         }

    //       }
    //     })
    //   },
      // 表单提交
      dataFormSubmit () {
        
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              async:true,
              url: this.$http.adornUrl(`/product/consumer/reg/sendcode`),
              method: 'post',
              data: this.$http.adornData({
                'consumerId': this.dataForm.consumerId || undefined,
                'username': this.dataForm.username,
                'level': this.dataForm.level,
                'count': this.dataForm.count,
                'status': 1,
                'email': this.dataForm.email,
                'phone': this.dataForm.phone,
                'ckey': this.dataForm.ckey
              })
            })
            this.$message({
                message: "成功申请，请填写验证码",
                type: "success"
            });
            this.$emit("changeStep",2);
          }
        })
      }
    },
    created(){
        // console.log(this.dataFormParent)
    //   this.init(this.$cookie.get("userid"));
    }
  }
</script>
